<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>员工列表页面</title>
    <script src="../js/jquery-1.12.4.js"></script>
</head>
<body>
    <table id="tb" align="center" border="1" cellspacing="0" cellpadding="5" bordercolor="red">
        <tr>
            <th>ID</th>
            <th>姓名</th>
            <th>工资</th>
            <th>年龄</th>
            <th>操作</th>
        </tr>

    </table>

</body>
<script>
    $(function(){
        $.ajax({
            type: "get",
            url: "/selectAllEmp",
            success:function(data) {
                let pageBean = JSON.parse(data);
                let empList = pageBean.data;
                for (let i = 0; i < empList.length; i++) {
                    let emp = empList[i];

                    let tr = document.createElement("tr");

                    let td1 = document.createElement("td");
                    $(td1).text(emp.id);
                    let td2 = document.createElement("td");
                    $(td2).text(emp.name);
                    let td3 = document.createElement("td");
                    $(td3).text(emp.salary);
                    let td4 = document.createElement("td");
                    $(td4).text(emp.age);

                    $(tr).append(td1);
                    $(tr).append(td2);
                    $(tr).append(td3);
                    $(tr).append(td4);


                    $("#tb").append(tr);
                }
            }
        });
    });
</script>
</html>